package com.liyu.service;

import com.liyu.mapper.GoodsMapper;
import com.liyu.pojo.Goods;
import com.liyu.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

/**
 * ��Ʒ������
 *
 * @author Yuhaotian
 * @date. 2022/10/31 14:33
 */
public class GoodsService {

    SqlSessionFactory factory = SqlSessionFactoryUtils.getSqlSessionFactory();

    public List<Goods> selectAllGoods() {
        //2. ��ȡSqlSession����
        SqlSession sqlSession = factory.openSession();

        //3. ��ȡMapper�ӿڵĴ������
        GoodsMapper goodsMapper = sqlSession.getMapper(GoodsMapper.class);
        List<Goods> goodsList = goodsMapper.selectAll();
        //5. �ͷ���Դ
        sqlSession.close();
        return goodsList;
    }

}
